const webSocket = require('ws')
// 创建websocket服务器
const wsServer = new webSocket.Server({
    port: 8001
})
const clients = []
wsServer.on('connection', (ws) => {
    clients.push(ws)
    ws.on('message', val => {
        clients.filter(item => item!==ws).forEach(item => {
            item.send(val)
        })
        console.log('val', val)
    })
})
// wsServer.on('message', (obj) => {
//     console.log('收到信息', obj)
// })
wsServer.on('open', _=>{
    console.log('open')
})

